package com.example.soscall.utils;

/**
 * Created by shengjieli on 18-1-17.<br>
 * Email address: shengjieli@ecarx.com.cn<br>
 */

public class TimeUtil {

    public static String formatCallTime(int seconds) {

        seconds = seconds % (24 * 60 * 60);

        String hour = formatTime(seconds / (60 * 60));
        String min = formatTime((seconds - seconds / (60 * 60) * 60 * 60) / 60);
        String sec = formatTime(seconds % 60);

        return hour + ":" + min + ":" + sec;
    }

    /**
     * 将时间格式化成两位数：如"00"
     *
     * @return
     */
    private static String formatTime(int time) {
        if (time < 0) {
            return "00";
        }
        if (time < 10) {
            return "0" + time;
        }
        return String.valueOf(time);
    }

}
